<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="gv-sub-content">
  <div class="gv-forms" layout="column">
    <form name="$ctrl.formApiLogging" ng-submit="$ctrl.save()" novalidate>
      <h1>API logging</h1>
      <div class="gv-form">
        <md-input-container class="md-block" flex-gt-xs>
          <md-checkbox
            ng-model="$ctrl.settings.logging.audit.enabled"
            aria-label="Audit on API Logging"
            ng-disabled="$ctrl.isReadonlySetting('logging.audit.enabled')"
          >
            Enable audit on API Logging consultation
            <md-tooltip ng-if="$ctrl.isReadonlySetting('logging.audit.enabled')">{{$ctrl.providedConfigurationMessage}}</md-tooltip>
          </md-checkbox>
        </md-input-container>
        <md-input-container class="md-block" flex-gt-xs>
          <md-checkbox
            ng-model="$ctrl.settings.logging.user.displayed"
            aria-label="End user on API Logging"
            ng-disabled="$ctrl.isReadonlySetting('logging.user.displayed')"
          >
            Display end user on API Logging (in case of OAuth2/JWT plan)
            <md-tooltip ng-if="$ctrl.isReadonlySetting('logging.user.displayed')">{{$ctrl.providedConfigurationMessage}}</md-tooltip>
          </md-checkbox>
        </md-input-container>
        <md-input-container class="md-block" flex-gt-xs>
          <md-checkbox
            ng-model="$ctrl.settings.logging.audit.trail.enabled"
            aria-label="Generate API Logging audit trail"
            ng-disabled="$ctrl.isReadonlySetting('logging.audit.trail.enabled')"
          >
            Generate API Logging audit events (API_LOGGING_ENABLED, API_LOGGING_DISABLED, API_LOGGING_UPDATED)
            <md-tooltip ng-if="$ctrl.isReadonlySetting('logging.audit.trail.enabled')">{{$ctrl.providedConfigurationMessage}}</md-tooltip>
          </md-checkbox>
        </md-input-container>
        <div class="gv-form-content" layout="column">
          <md-input-container class="md-block" flex-gt-xs>
            <label>Maximum duration (in milliseconds) when a logging mode is activated (0 means no max duration)</label>
            <input
              type="number"
              min="0"
              ng-model="$ctrl.settings.logging.maxDurationMillis"
              ng-disabled="$ctrl.isReadonlySetting('logging.default.max.duration')"
            />
            <md-tooltip ng-if="$ctrl.isReadonlySetting('logging.default.max.duration')">{{$ctrl.providedConfigurationMessage}}</md-tooltip>
          </md-input-container>
        </div>
      </div>
      <div class="md-actions gravitee-api-save-button" layout="row">
        <md-button
          class="md-raised"
          type="submit"
          permission
          permission-only="['environment-settings-c', 'environment-settings-u']"
          ng-disabled="$ctrl.formApiLogging.$pristine || $ctrl.formApiLogging.$invalid"
        >
          Save
        </md-button>
      </div>
    </form>
  </div>
</div>
